<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>风景音乐画廊</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            overflow: hidden;
            height: 100vh;
            background-color: #000;
        }

        .slideshow-container {
            position: relative;
            width: 100%;
            height: 100vh;
        }

        .slide {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            transition: opacity 1.5s ease-in-out;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .slide.active {
            opacity: 1;
        }

        .slide img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .slide-content {
            position: absolute;
            bottom: 80px;
            left: 0;
            width: 100%;
            text-align: center;
            color: white;
            padding: 20px;
            background: rgba(0, 0, 0, 0.5);
        }

        .slide-title {
            font-size: 2.5rem;
            margin-bottom: 10px;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
        }

        .slide-description {
            font-size: 1.2rem;
            max-width: 600px;
            margin: 0 auto;
        }

        .controls {
            position: absolute;
            bottom: 20px;
            left: 0;
            width: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 100;
        }

        .control-btn {
            background: rgba(255, 255, 255, 0.3);
            border: none;
            color: white;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            margin: 0 10px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            transition: background 0.3s;
        }

        .control-btn:hover {
            background: rgba(255, 255, 255, 0.5);
        }

        .music-control {
            position: absolute;
            top: 20px;
            right: 20px;
            z-index: 100;
        }

        .music-btn {
            background: rgba(255, 255, 255, 0.3);
            border: none;
            color: white;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            transition: background 0.3s;
        }

        .music-btn:hover {
            background: rgba(255, 255, 255, 0.5);
        }

        .progress-bar {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 5px;
            background: rgba(255, 255, 255, 0.2);
        }

        .progress {
            height: 100%;
            background: white;
            width: 0%;
            transition: width 0.5s;
        }

        .indicators {
            position: absolute;
            bottom: 80px;
            left: 0;
            width: 100%;
            display: flex;
            justify-content: center;
            z-index: 100;
        }

        .indicator {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.5);
            margin: 0 5px;
            cursor: pointer;
            transition: background 0.3s;
        }

        .indicator.active {
            background: white;
        }

        @media (max-width: 768px) {
            .slide-title {
                font-size: 1.8rem;
            }
            
            .slide-description {
                font-size: 1rem;
            }
        }
    </style>
</head>
<body>
    <div class="slideshow-container">
        <!-- 风景图片幻灯片 -->
        <div class="slide active">
            <img src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80" alt="山脉风景">
            <div class="slide-content">
                <h2 class="slide-title">壮丽山脉</h2>
                <p class="slide-description">高耸入云的山峰，覆盖着皑皑白雪，在阳光下闪耀着金色的光芒。</p>
            </div>
        </div>
        
        <div class="slide">
            <img src="https://images.unsplash.com/photo-1439066615861-d1af74d74000?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80" alt="湖泊风景">
            <div class="slide-content">
                <h2 class="slide-title">宁静湖泊</h2>
                <p class="slide-description">清澈的湖水倒映着蓝天白云，周围环绕着茂密的森林，宁静而美丽。</p>
            </div>
        </div>
        
        <div class="slide">
            <img src="https://images.unsplash.com/photo-1505142468610-359e7d316be0?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80" alt="森林风景">
            <div class="slide-content">
                <h2 class="slide-title">神秘森林</h2>
                <p class="slide-description">阳光透过茂密的树叶洒下斑驳的光影，空气中弥漫着泥土和青草的芳香。</p>
            </div>
        </div>
        
        <div class="slide">
            <img src="https://images.unsplash.com/photo-1469474968028-56623f02e42e?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80" alt="日落风景">
            <div class="slide-content">
                <h2 class="slide-title">绚丽日落</h2>
                <p class="slide-description">太阳缓缓沉入地平线，天空被染成一片绚丽的橙红色，美得令人窒息。</p>
            </div>
        </div>
        
        <div class="slide">
            <img src="https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80" alt="海滩风景">
            <div class="slide-content">
                <h2 class="slide-title">金色海滩</h2>
                <p class="slide-description">细软的金色沙滩，碧蓝的海水轻轻拍打着海岸，带来阵阵清凉的海风。</p>
            </div>
        </div>
        
        <!-- 控制按钮 -->
        <div class="controls">
            <button class="control-btn prev">❮</button>
            <button class="control-btn next">❯</button>
        </div>
        
        <!-- 音乐控制 -->
        <div class="music-control">
            <button class="music-btn">♪</button>
        </div>
        
        <!-- 进度条 -->
        <div class="progress-bar">
            <div class="progress"></div>
        </div>
        
        <!-- 指示器 -->
        <div class="indicators">
            <div class="indicator active"></div>
            <div class="indicator"></div>
            <div class="indicator"></div>
            <div class="indicator"></div>
            <div class="indicator"></div>
        </div>
    </div>

    <!-- 音频元素 -->
    <audio id="background-music" loop>
        <!-- 请将音乐文件路径替换为您的实际路径 -->
        <source src="./source/music.mp3" type="audio/mp3">
        您的浏览器不支持音频元素。
    </audio>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const slides = document.querySelectorAll('.slide');
            const indicators = document.querySelectorAll('.indicator');
            const prevBtn = document.querySelector('.prev');
            const nextBtn = document.querySelector('.next');
            const musicBtn = document.querySelector('.music-btn');
            const progress = document.querySelector('.progress');
            const audio = document.getElementById('background-music');
            
            let currentSlide = 0;
            let isPlaying = false;
            let autoSlideInterval;
            
            // 初始化
            function init() {
                // 尝试自动播放音乐
                playMusic();
                
                // 设置自动幻灯片切换
                startAutoSlide();
                
                // 添加触摸滑动支持
                let startX = 0;
                let endX = 0;
                
                document.addEventListener('touchstart', function(e) {
                    startX = e.touches[0].clientX;
                });
                
                document.addEventListener('touchend', function(e) {
                    endX = e.changedTouches[0].clientX;
                    handleSwipe();
                });
                
                function handleSwipe() {
                    if (startX - endX > 50) {
                        // 向左滑动
                        nextSlide();
                    } else if (endX - startX > 50) {
                        // 向右滑动
                        prevSlide();
                    }
                }
                
                // 键盘导航支持
                document.addEventListener('keydown', function(e) {
                    if (e.key === 'ArrowLeft') {
                        prevSlide();
                    } else if (e.key === 'ArrowRight') {
                        nextSlide();
                    } else if (e.key === ' ') {
                        toggleMusic();
                    }
                });
            }
            
            // 播放音乐
            function playMusic() {
                audio.play().then(() => {
                    isPlaying = true;
                    musicBtn.textContent = '♪';
                }).catch(error => {
                    console.log('自动播放被阻止:', error);
                    // 如果自动播放被阻止，显示提示
                    musicBtn.textContent = '▶';
                    isPlaying = false;
                });
            }
            
            // 切换音乐播放状态
            function toggleMusic() {
                if (isPlaying) {
                    audio.pause();
                    musicBtn.textContent = '▶';
                } else {
                    audio.play();
                    musicBtn.textContent = '♪';
                }
                isPlaying = !isPlaying;
            }
            
            // 开始自动幻灯片切换
            function startAutoSlide() {
                autoSlideInterval = setInterval(nextSlide, 5000);
            }
            
            // 停止自动幻灯片切换
            function stopAutoSlide() {
                clearInterval(autoSlideInterval);
            }
            
            // 显示指定幻灯片
            function showSlide(n) {
                // 更新当前幻灯片索引
                currentSlide = (n + slides.length) % slides.length;
                
                // 隐藏所有幻灯片
                slides.forEach(slide => {
                    slide.classList.remove('active');
                });
                
                // 更新指示器
                indicators.forEach(indicator => {
                    indicator.classList.remove('active');
                });
                
                // 显示当前幻灯片
                slides[currentSlide].classList.add('active');
                indicators[currentSlide].classList.add('active');
                
                // 更新进度条
                progress.style.width = `${(currentSlide + 1) / slides.length * 100}%`;
            }
            
            // 下一张幻灯片
            function nextSlide() {
                showSlide(currentSlide + 1);
            }
            
            // 上一张幻灯片
            function prevSlide() {
                showSlide(currentSlide - 1);
            }
            
            // 事件监听器
            prevBtn.addEventListener('click', function() {
                stopAutoSlide();
                prevSlide();
                startAutoSlide();
            });
            
            nextBtn.addEventListener('click', function() {
                stopAutoSlide();
                nextSlide();
                startAutoSlide();
            });
            
            musicBtn.addEventListener('click', toggleMusic);
            
            // 为每个指示器添加点击事件
            indicators.forEach((indicator, index) => {
                indicator.addEventListener('click', function() {
                    stopAutoSlide();
                    showSlide(index);
                    startAutoSlide();
                });
            });
            
            // 初始化应用
            init();
        });
    </script>
</body>
</html>